package cn.iocoder.yudao.module.bpm.message.redis;

import cn.iocoder.yudao.framework.mq.redis.core.RedisMQTemplate;
import cn.iocoder.yudao.module.bpm.message.ProcessTaskMessage;
import cn.iocoder.yudao.module.bpm.message.redis.dto.RedisBpmProcessTaskAssignedMessage;
import cn.iocoder.yudao.module.bpm.message.redis.dto.RedisBpmProcessTaskCancelledMessage;
import cn.iocoder.yudao.module.bpm.message.redis.dto.RedisBpmProcessTaskCompletedMessage;
import cn.iocoder.yudao.module.bpm.message.redis.dto.RedisBpmProcessTaskCreatedMessage;
import cn.iocoder.yudao.module.bpm.message.dto.BpmProcessTaskAssignedMessage;
import cn.iocoder.yudao.module.bpm.message.dto.BpmProcessTaskCancelledMessage;
import cn.iocoder.yudao.module.bpm.message.dto.BpmProcessTaskCompletedMessage;
import cn.iocoder.yudao.module.bpm.message.dto.BpmProcessTaskCreatedMessage;
import lombok.extern.log4j.Log4j2;

@Log4j2
public class RedisProcessTaskMessage implements ProcessTaskMessage {

    private final RedisMQTemplate redisMQTemplate;

    public RedisProcessTaskMessage(RedisMQTemplate redisMQTemplate) {
        this.redisMQTemplate = redisMQTemplate;
    }

    @Override
    public void onProcessInstanceTaskCreatedMsg(BpmProcessTaskCreatedMessage bpmProcessTaskCreatedMessage) {
        RedisBpmProcessTaskCreatedMessage msg = new RedisBpmProcessTaskCreatedMessage();
        msg.setBpmProcessMessage(bpmProcessTaskCreatedMessage);
        redisMQTemplate.send(msg);
    }

    @Override
    public void onProcessInstanceTaskAssignedMsg(BpmProcessTaskAssignedMessage bpmProcessTaskAssignedMessage) {
        RedisBpmProcessTaskAssignedMessage msg = new RedisBpmProcessTaskAssignedMessage();
        msg.setBpmProcessMessage(bpmProcessTaskAssignedMessage);
        redisMQTemplate.send(msg);
    }

    @Override
    public void onProcessInstanceTaskCleanMsg(BpmProcessTaskCancelledMessage bpmProcessTaskCancelledMessage) {
        RedisBpmProcessTaskCancelledMessage msg = new RedisBpmProcessTaskCancelledMessage();
        msg.setBpmProcessMessage(bpmProcessTaskCancelledMessage);
        redisMQTemplate.send(msg);
    }

    @Override
    public void onProcessInstanceTaskFinishedMsg(BpmProcessTaskCompletedMessage bpmProcessTaskCompletedMessage) {
        RedisBpmProcessTaskCompletedMessage msg = new RedisBpmProcessTaskCompletedMessage();
        msg.setBpmProcessMessage(bpmProcessTaskCompletedMessage);
        redisMQTemplate.send(msg);
    }
}
